package org.ccay.enumerable;

/**
 * EnumItem实现类
 * @author chaowangbang
 *
 */
public class PlainEnumItem implements EnumItem<Object>  {

	private static final long serialVersionUID = -8352027822765349688L;
	
	/**枚举字段类型*/
	private String type;
	/**枚举字段代码*/
	private String name;
	/**枚举字段值*/
	private String value;
	/**枚举字段名称*/
	private String displayValue;
	/**枚举字段索引*/
	private int index;
	/**枚举值来源*/
	private String source;
	
	public PlainEnumItem(){}


	public PlainEnumItem(String type, String name, String value,
			String displayValue, int index, String source) {
		this.type = type;
		this.name = name;
		this.value = value;
		this.displayValue = displayValue;
		this.index = index;
		this.source = source;
	}


	@Override
	public String getType() {
		return type;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public int getIndex() {
		return index;
	}
	
	@Override
	public String toString() {
		return type+"[name=" + name + ", value=" + value + ", displayValue=" + displayValue +"]";
	}

	@Override
	public String getDisplayValue(String language) {
		return EnumI18nUtil.getI18nName(this, language);
	}

	@Override
	public String getSource() {
		return source;
	}
	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}


	public String getDisplayValue() {
		return displayValue;
	}

	public void setDisplayValue(String displayValue) {
		this.displayValue = displayValue;
	}
	public EnumItem<Object> fromValue(String value) {
		return EnumUtil.getInstance().getByTypeValue(getType(),  getValue());
	}

}
